import Vue from 'vue'
import Router from 'vue-router'
import store from './store'

import Login from '@/views/login/Login.vue';
import Menu from '@/views/layout/Menu.vue';
import Home from '@/views/home/home.vue';
import CustomerList from '@/views/person/CustomerList.vue';
import StaffList from '@/views/person/StaffList.vue';
import ShopList from '@/views/shop/ShopList.vue';
import TyreList from '@/views/tyre/TyreList.vue';
import HistoryList from '@/views/case/HistoryList.vue';
import CaseList from '@/views/case/CaseList.vue';
import AuditList from '@/views/case/AuditList.vue';
import MessageList from '@/views/message/MessageList.vue';
import MessageDetail from '@/views/message/MessageDetail.vue';
import AccountList from '@/views/account/AccountList.vue';
import AccountEdit from '@/views/account/AccountEdit.vue';
import RoleList from '@/views/role/RoleList.vue';
import RoleEdit from '@/views/role/RoleEdit.vue';
import Setting from '@/views/setting/Setting.vue';
import Note from '@/views/setting/Note.vue';
import LogList from '@/views/log/LogList.vue';
import Import from '@/views/setting/Import.vue';

Vue.use(Router)

//解决重复点击菜单报错的问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export const routes_new=[
    {
       path:'/',
       name:'',
       component:Menu,
       children:[
          {
             path:'home',
             name:'home',
             component:Home,
             meta:{ title:'首页' }
          }
       ]
    },
    {
       path:'/person',
       name:'person',
       redirect:'/person/customerlist',
       component:Menu,
       meta: { title:'人员管理' },
       children:[
          {
             path:'customerlist',
             name:'customerlist',
             component:CustomerList,
             meta:{ title:'客户列表' }
          },
          {
             path:'stafflist',
             name:'stafflist',
             component:StaffList,
             meta:{ title:'理赔人员列表' }
          }
       ]
    },
    {
       path:'/shop',
       name:'shop',
       redirect:'/shop/shoplist',
       component:Menu,
       meta: { title:'门店管理' },
       children:[
          {
             path:'shoplist',
             name:'shoplist',
             component:ShopList,
             meta:{ title:'门店列表' }
          }
       ]
    },
    {
       path:'/tyre',
       name:'tyre',
       redirect:'/tyre/tyrelist',
       component:Menu,
       meta: { title:'轮胎管理' },
       children:[
          {
             path:'tyrelist',
             name:'tyrelist',
             component:TyreList,
             meta:{ title:'轮胎列表' }
          }
       ]
    },
    {
       path:'/case',
       name:'case',
       redirect:'/case/caselist',
       component:Menu,
       meta: { title:'理赔案件' },
       children:[
          {
             path:'historylist',
             name:'historylist',
             component:HistoryList,
             meta:{ title:'历史理赔记录' }
          },
          {
             path:'caselist',
             name:'caselist',
             component:CaseList,
             meta:{ title:'理赔记录' }
          },
          {
             path:'auditlist',
             name:'auditlist',
             component:AuditList,
             meta:{ title:'审核列表' }
          }
       ]
    },
    {
       path:'/message',
       name:'message',
       redirect:'/message/messagelist',
       component:Menu,
       meta: { title:'留言管理' },
       children:[
          {
             path:'messagelist',
             name:'messagelist',
             component:MessageList,
             meta:{ title:'留言列表' }
          },
          {
             path:'messagedetail',
             name:'messagedetail',
             component:MessageDetail,
             meta:{ title:'留言详情' }
          }
       ]
    },
    {
        path:'/system',
        name:'system',
        redirect: '/system/accountlist',
        component:Menu,
        meta:{ title:'系统设置' },
        children:[
            {
                path:'accountlist',
                name:'accountlist',
                component: AccountList,
                meta:{ title:'用户列表' }
            },
            {
                path:'accountEdit',
                name:'accountEdit',
                component: AccountEdit,
                meta:{ title:'用户编辑' }
            },
            {
                path:'rolelist',
                name:'rolelist',
                component: RoleList,
                meta:{ title:'角色列表' }
            },
            {
                path:'roleedit',
                name:'roleedit',
                component: RoleEdit,
                meta:{ title:'角色编辑' }
            },
            {
                path:'setting',
                name:'setting',
                component: Setting,
                meta:{ title:'设置相关' }
            },
            {
                path:'note',
                name:'note',
                component: Note,
                meta:{ title:'短信配置' }
            },
            {
                path:'loglist',
                name:'loglist',
                component: LogList,
                meta:{ title:'系统日志' }
            },
            {
                path:'import',
                name:'import',
                component: Import,
                meta:{ title:'数据导入' }
            },
        ]
    },
    {
        path:'/login',
        name:'login',
        component:Login
    }
];

export default  new Router({
    //嵌套路由，设置布局
    //mode: 'history',
    routes:routes_new
})
